#!/usr/bin/env python3
"""
3D 扫描启动器 - 选择扫描模式
"""
import sys
import subprocess
from pathlib import Path
import tkinter as tk
from tkinter import ttk

class ScanLauncher:
    def __init__(self, root):
        self.root = root
        self.root.title("3D 扫描启动器")
        self.root.geometry("500x400")
        
        self.venv_python = Path(".venv/Scripts/python.exe")
        
        self.setup_ui()
    
    def setup_ui(self):
        # 标题
        title = tk.Label(
            self.root,
            text="🎯 ORB-SLAM3 3D 扫描系统",
            font=("Arial", 18, "bold"),
            fg="#2196F3"
        )
        title.pack(pady=20)
        
        # 说明
        info = tk.Label(
            self.root,
            text="请选择扫描模式：",
            font=("Arial", 12)
        )
        info.pack(pady=10)
        
        # 按钮框架
        btn_frame = tk.Frame(self.root)
        btn_frame.pack(pady=20)
        
        # 静态扫描按钮
        static_btn = tk.Button(
            btn_frame,
            text="📷 静态多角度扫描\n(推荐)",
            command=self.launch_static,
            bg="#4CAF50",
            fg="white",
            font=("Arial", 12, "bold"),
            width=20,
            height=5
        )
        static_btn.grid(row=0, column=0, padx=10, pady=10)
        
        static_desc = tk.Label(
            btn_frame,
            text="✅ 每个角度静止录制\n✅ 质量高、无空洞\n✅ 适合小物体/房间",
            justify=tk.LEFT,
            font=("Arial", 9),
            fg="#555"
        )
        static_desc.grid(row=1, column=0, padx=10)
        
        # 动态扫描按钮
        dynamic_btn = tk.Button(
            btn_frame,
            text="🎬 动态连续扫描",
            command=self.launch_dynamic,
            bg="#2196F3",
            fg="white",
            font=("Arial", 12, "bold"),
            width=20,
            height=5
        )
        dynamic_btn.grid(row=0, column=1, padx=10, pady=10)
        
        dynamic_desc = tk.Label(
            btn_frame,
            text="⚠️ 连续移动相机\n⚠️ 易失败、有空洞\n⚠️ 仅用于测试",
            justify=tk.LEFT,
            font=("Arial", 9),
            fg="#555"
        )
        dynamic_desc.grid(row=1, column=1, padx=10)
        
        # 底部提示
        tip = tk.Label(
            self.root,
            text="💡 提示：Astra Pro 深度覆盖率 88.7%，适合高质量 3D 重建",
            font=("Arial", 9),
            fg="#666",
            bg="#f0f0f0",
            padx=10,
            pady=10
        )
        tip.pack(side=tk.BOTTOM, fill=tk.X, pady=10)
    
    def launch_static(self):
        subprocess.Popen([
            str(self.venv_python),
            "tools/gui_static_scan.py"
        ])
        self.root.destroy()
    
    def launch_dynamic(self):
        subprocess.Popen([
            str(self.venv_python),
            "tools/gui_dynamic_scan.py"
        ])
        self.root.destroy()

def main():
    root = tk.Tk()
    app = ScanLauncher(root)
    root.mainloop()

if __name__ == "__main__":
    main()





